package com.ruoyi.web.controller.pc;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.WmsDeliveryPlanDetail;
import com.ruoyi.business.service.IWmsDeliveryPlanDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库计划货物信息Controller
 *
 * @author ruoyi
 * @date 2024-01-13
 */
@RestController
@RequestMapping("/business/deliveryPlanDetail")
public class WmsDeliveryPlanDetailController extends BaseController
{
    @Autowired
    private IWmsDeliveryPlanDetailService wmsDeliveryPlanDetailService;

    /**
     * 查询出库计划货物信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WmsDeliveryPlanDetail wmsDeliveryPlanDetail)
    {
        startPage();
        List<WmsDeliveryPlanDetail> list = wmsDeliveryPlanDetailService.selectWmsDeliveryPlanDetailList(wmsDeliveryPlanDetail);
        return getDataTable(list);
    }

    /**
     * 查询出库计划货物信息列表
     */
    @GetMapping("/query")
    public AjaxResult query(WmsDeliveryPlanDetail wmsDeliveryPlanDetail)
    {
        List<WmsDeliveryPlanDetail> list = wmsDeliveryPlanDetailService.selectWmsDeliveryPlanDetailList(wmsDeliveryPlanDetail);
        return AjaxResult.success(list);
    }

//    /**
//     * 导出出库计划货物信息列表
//     */
//    @Log(title = "出库计划货物信息", businessType = BusinessType.EXPORT)
//    @GetMapping("/export")
//    public AjaxResult export(WmsDeliveryPlanDetail wmsDeliveryPlanDetail)
//    {
//        List<WmsDeliveryPlanDetail> list = wmsDeliveryPlanDetailService.selectWmsDeliveryPlanDetailList(wmsDeliveryPlanDetail);
//        ExcelUtil<WmsDeliveryPlanDetail> util = new ExcelUtil<WmsDeliveryPlanDetail>(WmsDeliveryPlanDetail.class);
//        return util.exportExcel(list, "出库计划货物信息数据");
//    }

//    /**
//     * 获取出库计划货物信息详细信息
//     */
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return AjaxResult.success(wmsDeliveryPlanDetailService.selectWmsDeliveryPlanDetailById(id));
//    }

    /**
     * 新增出库计划货物信息
     */
    @Log(title = "出库计划货物信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsDeliveryPlanDetail wmsDeliveryPlanDetail)
    {
        wmsDeliveryPlanDetail.setCreateBy(getUsername());
        return toAjax(wmsDeliveryPlanDetailService.insertWmsDeliveryPlanDetail(wmsDeliveryPlanDetail));
    }

    /**
     * 修改出库计划货物信息
     */
    @Log(title = "出库计划货物信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsDeliveryPlanDetail wmsDeliveryPlanDetail)
    {
        wmsDeliveryPlanDetail.setUpdateBy(getUsername());
        return toAjax(wmsDeliveryPlanDetailService.updateWmsDeliveryPlanDetail(wmsDeliveryPlanDetail));
    }

    /**
     * 删除出库计划货物信息
     */
    @Log(title = "出库计划货物信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsDeliveryPlanDetailService.deleteWmsDeliveryPlanDetailByIds(ids));
    }
}
